<template>


	<div class="people_info">
		<div class="header">
			<van-nav-bar
				title="意见反馈"
				left-arrow
        @click-left="onClickLeft"
				/>
		</div>

		<div class="peole_content">
			<p>
				问题类型
			</p>
			<div class="btn_content_er">
				<van-button type="default" :class="{'sj_cl':type_v=='0'}" @click="click_type('0')">建议</van-button>
				<van-button type="default" :class="{'sj_cl':type_v=='1'}" @click="click_type('1')">吐槽</van-button>
				<van-button type="default" :class="{'sj_cl':type_v=='2'}" @click="click_type('2')">其他</van-button>
			</div>
			<p>
				反馈内容
			</p>


			<van-cell-group>
			  <van-field
          v-model="content"
			    type="textarea"
			    placeholder="请输入意见反馈"
			    rows="4"
			    autosize
          maxlength="100"
			  />
     </van-cell-group>




    <van-button type="primary" size="large" style="border:none" class="sub_fankui" @click="sub_info">提交反馈</van-button>




		</div>
		</div>
</template>
<script>
export default {
    data() {
        return {
            content:'',
            type_v:'',
            user:''
        }
    },
    mounted:function(){
        const that = this;
        let local_user = localStorage.getItem("user");
        if (local_user != undefined && local_user != "undefined") {
            let user = JSON.parse(local_user);
            that.user = user;
        }
    },
    methods:{

        onClickLeft(){
            this.$router.back(-1);
        },
        click_type(type){

          this.type_v = type;
        },
        sub_info(){
            const that = this;
            let type_v = that.type_v;
            let content = that.content;
            console.log("type_v:"+type_v);

            if(type_v ==''){
                that.$toast("请选择问题类型");
                return false;
            }
            if(content ==''){
                that.$toast("请输入意见反馈");
                return false;
            }
            console.log(that.user);
            var userId = '';
            if(that.user != ''){
                userId = that.user.userId;
            }
            let params = "type="+type_v+"&content="+content+"&userId="+userId;
            that.$sendRequest('/sys/feedback',params).then(function(res){
                console.log(res.data)
                if(res.data.code ==0){
                    that.$router.push({
                        path: "/myself"
                    });
                }else if(res.data.code ==2){
                    that.$toast(res.data.msg);
                }
            })

        }
    }
}
</script>
<style scoped="scoped">
	.header>>>.van-cell__title{
		  width: 63px !important;
	}
	/*.header>>>.van-field__control{
		height: 12vh;
	}*/
  .sj_cl{
    background: #4C9FFD;
    color: #ffffff;
  }
	.people_info{
		background: rgb(245,245,245);
	}
	.header >>> .van-cell-group div:nth-child(4){
		 height: 16vh;
	}
	.btn_content_er{
		background: #fff;
		padding: 4vw;
	}
	.peole_content p{
		text-align: left;
    margin-left: 6vw;
    margin: 0;
    padding: 2vw;
    font-size: 12px;
	}
	.btn_content_er{
		display: flex;
		justify-content:space-around;
	}
	.sub_fankui{
		position:fixed;
		bottom: 0;
		left: 0;
	}
	.people_info >>> .van-button--primary{
		 background: #4C9FFD;
	}
	.text{
		color: red;
	}
	.header >>> .van-icon-arrow-left{
		color: #2c3e50;
	}
</style>

